import 'package:flutter/material.dart';

class SplashPage extends StatefulWidget {
  @override
  State<StatefulWidget> createState() {
    // TODO: implement createState
    return SplashState();
  }
}

class SplashState extends State<SplashPage> {
  @override
  void initState() {
    // TODO: implement initState
    super.initState();
    startCountDown();
  }

  Future<void> startCountDown() async {
    Future.delayed(new Duration(seconds: 3), () {
      // 只在倒计时结束时回调
      Navigator.pushNamedAndRemoveUntil(
          context, "homePage", (Route<dynamic> route) => false);
    });
  }

  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return Scaffold(
      body: Image.asset('images/splash.jpeg',
          fit: BoxFit.fill,
          width: double.infinity,
          height: double.infinity),
    );
  }
}
